<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.CreateCourseTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>


            <h:form>
                <h:panelGrid columns="2">
                    <p:outputLabel value="#{bundle.CreateCourseLabel_courseName}" for="courseName" />
                    <p:inputText id="courseName" value="#{treeBeanModified.selectedNode.entity.courseName}" title="#{bundle.CreateCourseTitle_courseName}" required="true"/>

                    <p:outputLabel value="Course Description" for="courseDescription" />
                    <p:inputTextarea rows="7" cols="33" id="courseDescription" value="#{treeBeanModified.selectedNode.entity.courseDescription}" title="Course Description" onchange=""/>

                    <p:outputLabel value="#{bundle.CreateCourseLabel_nbreWeeks}" for="nbreWeeks" />
                    <p:inputText id="nbreWeeks" value="#{treeBeanModified.selectedNode.entity.nbreWeeks}" title="#{bundle.CreateCourseTitle_nbreWeeks}" required="true"/>

                    <h:outputLabel value="#{bundle.CreateCourseLabel_idField}" for="idField" />
                    <p:selectOneMenu  id="iField" value="#{treeBeanModified.selectedNode.entity.idField}"  required="true" requiredMessage="#{bundle.CreateCourseRequiredMessage_idField}" onchange="">
                        <f:selectItems value="#{fieldController.itemsAvailableSelectOne}"/>
                    </p:selectOneMenu>
                </h:panelGrid>
                <br />
                <p:growl id="messages" showDetail="true"/>

                <h:commandLink action="#{treeBeanModified.createcourse()}" value="#{bundle.CreateCourseSaveLink}" />

            </h:form>
            <h:form enctype="multipart/form-data">

                <p:fileUpload fileUploadListener="#{fileUploadBean.handleFileUploadPhotoModified}"
                              mode="advanced" 
                              update="messages,myimage"
                              sizeLimit="5242880" 
                              invalidSizeMessage="The maximum file size allowed is 5 Megabyte !"
                              allowTypes="/(\.|\/)(png|jpe?g)$/"

                              >

                </p:fileUpload>

                <p:growl id="messages" showDetail="true"/>
                <p:graphicImage id="myimage" width="200" height="150"  library="ContentFile" name="#{treeBeanModified.selectedNode.entity.photo}"/>


            </h:form>
        </ui:define>
    </ui:composition>

</html>
